﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.IO;

#pragma warning disable 1591

namespace OpGen.Compiler.Generator.XML
{
    public class XMLExporter
    {
        private ProjectElement _project;

        public XMLExporter(ProjectElement project)
        {
            _project = project;
        }

        public void Save(string filename)
        {
            var fileInfo = new FileInfo(filename);

            using (var xw = new XmlTextWriter(filename, System.Text.Encoding.Default) )
            {
                xw.WriteStartElement("opgen");



                xw.WriteEndElement();
            }
        }

        public void Preferences(XmlTextWriter xw)
        {
            xw.WriteStartElement("preferences");

            if (_project.BuildCodeEnum)
            {
                xw.WriteStartElement("codeenum");
                xw.WriteAttributeString("namespace", _project.CodeEnumNamespace.Namespace.Elementname);
                xw.WriteAttributeString("name", _project.CodeEnumNamespace.ChildElements[0].Elementname);

                switch (_project.CodeEnumNamespace.ChildElements[0].Modifier)
                {
                    case Modifiers.Private:
                        xw.WriteAttributeString("name", "private");
                        break;
                    case Modifiers.Public:
                        xw.WriteAttributeString("name", "public");
                        break;
                    case Modifiers.Internal:
                        xw.WriteAttributeString("name", "internal");
                        break;
                    case Modifiers.Protected:
                        xw.WriteAttributeString("name", "protected");
                        break;
                    case Modifiers.None:
                    case Modifiers.Unkown:
                    default:
                        break;

                }
            }


            xw.WriteEndElement();
        }
    }
}
